package com.wfx.controller;


import com.wfx.entity.*;
import com.wfx.service.IWxbOrderService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhu
 * @since 2021-01-23
 */
@RestController
@RequestMapping("/order")
@CrossOrigin
public class WxbOrderController {

    @Autowired
    private IWxbOrderService iWxbOrderService;

    @PostMapping("/search")
    @ApiOperation("分页加条件")
    public PageResult<WxbOrder> search(@RequestBody @ApiParam("分页条件") PageDTO<WxbOrder> pageDTO){
        if (pageDTO.getLimit() == null||pageDTO.getPage()==null) {
            pageDTO.setPage(1);
            pageDTO.setLimit(5);
        }
        return iWxbOrderService.search(pageDTO);
    }



    @PostMapping("save")
    public Result saveOrder(@RequestBody OrderDto orderDto) {

        return iWxbOrderService.saveOrder(orderDto);
    }

}
